<?php

include_once('../../base/Constants.php');
include_once('../../base/DBHelper.php');
include_once('../../base/SQLBuilder.php');
include_once('../../base/Response.php');
header("content-type:text/html;charset=utf8");

$response = new Response();
$userName = isset($_GET['username']) ? $_GET['username'] : "";
$password = isset($_GET['password']) ? $_GET['password'] : "";
if ($userName == '' || $password == '') {
	$response->msg = "用户名和密码不能为空";
	die($response->toJson());
}

$dbHelper = new DBHelper();
$sqlBuilder = new SQLBuilder();
$sqlStr = $sqlBuilder->select(TABLE_ADMIN)
	->where("name='$userName' and password='$password'")
	->build();

try {
	$dbHelper->connectDB();
	$data = $dbHelper->selectSQL($sqlStr);
	if ($data != null && count($data) > 0) {
		$response->code = RESPONSE_OK;
		$response->msg = "登录成功";
	} else {
		$response->msg = "用户名或密码错误";
	}
} catch (Exception $e) {
	
	$response->msg = $e->getMessage();
}
echo $response->toJson();
$dbHelper->disconnectDB();

?>